﻿@inject TokenProvider TokenProvider

<CascadingAuthenticationState>
    <Microsoft.AspNetCore.Components.Routing.Router AppAssembly="@typeof(App).Assembly"
                                                    AdditionalAssemblies='new List<Assembly>(){ Assembly.Load("Masa.Stack.Components")}'>
        <Found Context="routeData">
            <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
            <FocusOnNavigate RouteData="@routeData" Selector="h1" />
        </Found>
        <NotFound>
            <MApp>
                <NotFound />
            </MApp>
        </NotFound>
    </Microsoft.AspNetCore.Components.Routing.Router>
</CascadingAuthenticationState>
@code {
    [Parameter]
    public TokenProvider InitialState { get; set; } = null!;

    protected override Task OnInitializedAsync()
    {
        TokenProvider.AccessToken = InitialState.AccessToken;
        TokenProvider.RefreshToken = InitialState.RefreshToken;
        TokenProvider.IdToken = InitialState.IdToken;
        return base.OnInitializedAsync();
    }
}